//import request from '@/utils/request'
import http from '@/api/request'
import axios from 'axios'
import { getToken } from '@/utils/auth'
import { getConfig } from '@/config/config'
import CryptoJS from "crypto-js"

const api = {
  // 根据船员id获取证书列表
  getList(query) {
    // return request({
    //   url: '/basicInfo/tug/page',
    //   method: 'get',
    //   params: query
    // })
    return http({
      url: '/tug-api/basicInfo/tug/page',
      method: 'get',
      params: query
  })
  },
  // 根据Id查询单条
  getDetailById(id) {
    return http({
      url: `/tug-api/basicInfo/tug/${id}`,
      method: 'get'
    })
  },
  // 新建
  save(data) {
    return http({
      url: '/tug-api/basicInfo/tug/save',
      method: 'post',
      data: data
    })
  },
  // 修改
  update(data) {
    return http({
      url: '/tug-api/basicInfo/tug/update',
      method: 'post',
      data: data
    })
  },
  //删除
  remove(ids) {
    return http({
      url: `/tug-api/basicInfo/tug/remove`,
      method: 'post',
      params: ids
    })
  },
  //导出模板
  exportTemplate() {
	  return axios({
	  		url: `/tug-api/basicInfo/tug/exportTemplate`,
	  		method: 'get',
	  		responseType:'blob',
	  		headers: {
	  			  'Authorization' : `Basic ${CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(`${getConfig('clientId')}:${getConfig('clientSecret')}`))}`,
	  			 'qdport-Auth': 'bearer ' + getToken(),
					 'token':getToken()
	  		  },
	  	})
  },
  //导出数据
  exportData(params) {
	  return axios({
	  		url: `/tug-api/basicInfo/tug/exportData`,
	  		method: 'get',
	  		responseType:'blob',
			params:params,
	  		headers: {
	  			  'Authorization' : `Basic ${CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(`${getConfig('clientId')}:${getConfig('clientSecret')}`))}`,
	  			 'qdport-Auth': 'bearer ' + getToken(),
					 'token':getToken()
	  		  },
	  	})
  },
  //导入
  importData(data) {
    return http({
      url: `/tug-api/basicInfo/tug/importTug`,
      method: 'post',
      data: data
    })
  },
  
}
export default api

